package com.xish.api.poi;

import com.xish.model.bean.WzmPoi;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.jdbc.query.QueryDslJdbcTemplate;
import org.springframework.stereotype.Repository;

import static com.xish.model.table.QWzmPoi.wzmPoi;

@Repository
public class PoiMysqlDao {

    private static final Logger LOG = LoggerFactory.getLogger(PoiMysqlDao.class);

    @Autowired
    private QueryDslJdbcTemplate jdbcTemplate;

    public WzmPoi findById(int id) {
        WzmPoi item = jdbcTemplate.queryForObject(
                jdbcTemplate.newSqlQuery().from(wzmPoi).where(wzmPoi.id.eq(id)), wzmPoi);

        if (item == null) {
            LOG.warn("WzmPoi not found, id={}", id);
        }

        return item;
    }
}
